package cn.supermarket.controller;

import cn.supermarket.pojo.dto.RefundAddNew;
import cn.supermarket.pojo.vo.RefundDetailsVO;
import cn.supermarket.service.iservice.IRefundService;
import cn.supermarket.service.iservice.IVIPService;
import cn.supermarket.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Api(tags = "退款记录")
@RestController
@RequestMapping("/refund")
public class RefundController extends BaseController {

    @Autowired
    IRefundService refundService;


    @PostMapping("/insert")
    @ApiOperation("添加退款记录")
    public JsonResult<String> insertRefund(@RequestBody RefundAddNew refundAddNew) {
        refundService.insert(refundAddNew);
        return JsonResult.ok("添加退款记录成功");
    }

    @GetMapping("/select/collect")
    @ApiOperation("照收货人查询")
    public JsonResult<List<RefundDetailsVO>> selectByCollect(String collect){
        return JsonResult.ok(refundService.selectByCollect(collect));
    }

    @GetMapping("/select/number")
    @ApiOperation("按照单号查询")
    public JsonResult<RefundDetailsVO> selectByNumber(String number){
        return JsonResult.ok(refundService.selectByNumber(number));
    }

    @GetMapping("/select/order/number")
    @ApiOperation("按照订单号查询")
    public JsonResult<RefundDetailsVO> selectByOrderNumber(String orderNumber){
        return JsonResult.ok(refundService.selectByOrderNumber(orderNumber));
    }

    @GetMapping("/select/supplier")
    @ApiOperation("按照供货商查询")
    public JsonResult<List<RefundDetailsVO>> selectBySupplier(String supplier){
        return JsonResult.ok(refundService.selectBySupplier(supplier));
    }



    @GetMapping("/select/date")
    @ApiOperation("按照日期段查询")
    public JsonResult<List<RefundDetailsVO>> selectListByDatetime(Date dateStart,Date dateEnd){
        return JsonResult.ok(refundService.selectListByDatetime(dateStart, dateEnd));
    }

    @GetMapping("/update/cancel")
    @ApiOperation("将退款记录作废")
    public JsonResult<String> updateIsCancel(Long id){
        refundService.updateIsCancel(id);
        return JsonResult.ok("修改成");
    }

    @GetMapping("/update/display")
    @ApiOperation("修改记录是否可见")
    public JsonResult<String> updateIsDisplay( Long id, Integer isDisplay){
        refundService.updateIsDisplay(id, isDisplay);
        return JsonResult.ok("记录可见行已修改");
    }

    @GetMapping("/update/enable")
    @ApiOperation("修改记录是否锁定")
    public JsonResult<String> updateIsEnable(Long id,Integer enable){
        refundService.updateIsEnable(id, enable);
        return JsonResult.ok("记录是否锁定已修改完成");
    }

    @PostMapping("/update/other")
    @ApiOperation("修改退款记录备注")
    public JsonResult<String> updateOther(Long id,String other){
        refundService.updateOther(id, other);
        return JsonResult.ok("备注修改完成");
    }



}
